package com.ruoyi.boss.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.boss.domain.CarMachineAppVersions;
import com.ruoyi.boss.service.ICarMachineAppVersionsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 车机端APP版本管理（含新增字段）Controller
 * 
 * @author nz
 * @date 2025-08-19
 */
@RestController
@RequestMapping("/carVersions")
public class CarMachineAppVersionsController extends BaseController
{
    @Autowired
    private ICarMachineAppVersionsService carMachineAppVersionsService;

    /**
     * 查询车机端APP版本管理（含新增字段）列表
     */
    @RequiresPermissions("boss:carVersions:list")
    @GetMapping("/list")
    public TableDataInfo list(CarMachineAppVersions carMachineAppVersions)
    {
        startPage();
        List<CarMachineAppVersions> list = carMachineAppVersionsService.selectCarMachineAppVersionsList(carMachineAppVersions);
        return getDataTable(list);
    }

    /**
     * 导出车机端APP版本管理（含新增字段）列表
     */
    @RequiresPermissions("boss:carVersions:export")
    @Log(title = "车机端APP版本管理（含新增字段）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarMachineAppVersions carMachineAppVersions)
    {
        List<CarMachineAppVersions> list = carMachineAppVersionsService.selectCarMachineAppVersionsList(carMachineAppVersions);
        ExcelUtil<CarMachineAppVersions> util = new ExcelUtil<CarMachineAppVersions>(CarMachineAppVersions.class);
        util.exportExcel(response, list, "车机端APP版本管理（含新增字段）数据");
    }

    /**
     * 获取车机端APP版本管理（含新增字段）详细信息
     */
    @RequiresPermissions("boss:carVersions:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(carMachineAppVersionsService.selectCarMachineAppVersionsById(id));
    }

    /**
     * 新增车机端APP版本管理（含新增字段）
     */
    @RequiresPermissions("boss:carVersions:add")
    @Log(title = "车机端APP版本管理（含新增字段）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarMachineAppVersions carMachineAppVersions)
    {
        return toAjax(carMachineAppVersionsService.insertCarMachineAppVersions(carMachineAppVersions));
    }

    /**
     * 修改车机端APP版本管理（含新增字段）
     */
    @RequiresPermissions("boss:carVersions:edit")
    @Log(title = "车机端APP版本管理（含新增字段）", businessType = BusinessType.UPDATE)
    @GlobalTransactional(name = "update-carVersions", rollbackFor = Exception.class)
    @PutMapping
    public AjaxResult edit(@RequestBody CarMachineAppVersions carMachineAppVersions)
    {
        return toAjax(carMachineAppVersionsService.updateCarMachineAppVersions(carMachineAppVersions));
    }

    /**
     * 删除车机端APP版本管理（含新增字段）
     */
    @RequiresPermissions("boss:carVersions:remove")
    @Log(title = "车机端APP版本管理（含新增字段）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(carMachineAppVersionsService.deleteCarMachineAppVersionsByIds(ids));
    }
}
